<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>立即执行函数</title>
</head>
<body>
<script>
    var name="World!";
    (function() {
        console.log(name)   //world
        console.log(typeof name==="undefined")   //flase
        if(typeof name==="undefined") {
            // var name="Jack";
            console.log("Goodbye"+name);
        } else {
            console.log("Hello"+name);  //hello world
        }
    })();
    (function() {
        console.log(name)   //undefined
        console.log(typeof name==="undefined")   //true
        if(typeof name==="undefined") {
            var name="Jack";
            console.log("Goodbye"+name);  //Goodbye Jack
        } else {
            console.log("Hello"+name);
        }
    })();


</script>
</body>
</html>